from sanic import Sanic
from sanic.response import json
from sanic_jinja import generate_template
from sanic_cors import CORS
import asyncio

app = Sanic(__name__)
app.static('/static', './static')
# 解决跨域
CORS(app)
template = generate_template('sanic_demo')
'''
here are some libraries which is for you to install

pip install sanic
pip install sanic-jinja2
pip install Sanic-Jinja
pip install sanic_cors
'''


@app.route("/")
async def index(request):
    data = {"code": 0}
    await asyncio.sleep(0)
    # return json(data)
    return template('index.html')


if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8000, auto_reload=True)